self.restart_count = 0
self.vcpus = 1
- self.vcpusdb = {}
self.bootloader = None
self.device_model_pid = 0
except:
raise VmError('invalid vcpus value')
- def exportVCPUSToDB(self, vcpus):
- for v in range(0,vcpus):
- path = "/cpu/%d"%(v)
- if not self.vcpusdb.has_key(path):
- self.vcpusdb[path] = self.db.addChild(path)
- db = self.vcpusdb[path]
- log.debug("writing key availability=online to path %s in store"%(path))
- db['availability'] = "online"
- db.saveDB(save=True)
+ def configure_vcpus(self, vcpus):
+ d = {}
+ for v in range(0, vcpus):
+ d["cpu/%d/availability" % v] = "online"
+ xstransact.Write(self.path, d)
def init_image(self):
"""Create boot image handler for the domain.
IntroduceDomain(self.id, self.store_mfn, self.store_channel.port1,
self.path)
# get the configured value of vcpus and update store
- self.exportVCPUSToDB(self.vcpus)
+ self.configure_vcpus(self.vcpus)
def delete(self):
"""Delete the vm's db.
def vcpu_hotplug(self, vcpu, state):
"""Disable or enable VCPU in domain.
"""
- db = ""
- try:
- db = self.vcpusdb['/cpu/%d'%(vcpu)]
- except:
- log.error("Invalid VCPU")
+ if vcpu > self.vcpus:
+ log.error("Invalid VCPU %d" % vcpu)
return
-
- if self.store_channel:
- if int(state) == 0:
- db['availability'] = "offline"
- else:
- db['availability'] = "online"
-
- db.saveDB(save=True)
+ if int(state) == 0:
+ availability = "offline"
+ else:
+ availability = "online"
+ xstransact.Write(self.path, "cpu/%d/availability" % vcpu, availability)
def shutdown(self, reason):
if not reason in shutdown_reasons.values():
else:
raise
# get run-time value of vcpus and update store
- self.exportVCPUSToDB(dom_get(self.id)['vcpus'])
+ self.configure_vcpus(dom_get(self.id)['vcpus'])
def vm_field_ignore(_, _1, _2, _3):